package com.icinfo.cloud.provider.punish.fastcase.service.impl;

import com.icinfo.cloud.provider.punish.fastcase.dto.FastCaseAutoEndSaveDto;
import com.icinfo.cloud.provider.punish.fastcase.service.IFastCaseDocumentRecordService;
import com.icinfo.cloud.provider.punish.fastcase.service.IFastCaseEndService;
import com.icinfo.cloud.provider.punish.ucase.casemain.mapper.CaseMainDetailAuxiliaryInfoMapper;
import com.icinfo.cloud.provider.punish.ucase.casemain.mapper.CaseMainDetailInfoMapper;
import com.icinfo.cloud.provider.punish.ucase.casemain.model.CaseMainDetailAuxiliaryInfo;
import com.icinfo.cloud.provider.punish.ucase.casemain.model.CaseMainDetailInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.time.LocalDate;


/**
 * @author shishengyao
 * @description
 * @date 2023/8/29
 */
@Service
public class FastCaseEndServiceImpl implements IFastCaseEndService {
    /**
     * 日志记录器
     */
    private static final Logger logger = LoggerFactory.getLogger(FastCaseEndServiceImpl.class);
    @Resource
    private IFastCaseDocumentRecordService fastCaseDocumentRecordService;
    @Resource
    private CaseMainDetailInfoMapper caseMainDetailInfoMapper;
    @Resource
    private CaseMainDetailAuxiliaryInfoMapper caseMainDetailAuxiliaryInfoMapper;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveFastCaseAutoEnd(FastCaseAutoEndSaveDto saveDto) {
        CaseMainDetailInfo caseMainDetailInfo=new CaseMainDetailInfo();
        caseMainDetailInfo.setExecuteWay("自觉履行");
        caseMainDetailInfo.setExecuteFinishDate(LocalDate.now());
        caseMainDetailInfo.setCaseId(saveDto.getCaseId());
        caseMainDetailInfoMapper.updateByPrimaryKeySelective(caseMainDetailInfo);
        CaseMainDetailAuxiliaryInfo caseMainDetailAuxiliaryInfo=new CaseMainDetailAuxiliaryInfo();
        caseMainDetailAuxiliaryInfo.setExecuteWay("自觉履行");
        caseMainDetailAuxiliaryInfo.setExecuteFinishDate(LocalDate.now());
        caseMainDetailAuxiliaryInfo.setCaseId(saveDto.getCaseId());
        caseMainDetailAuxiliaryInfoMapper.updateByPrimaryKeySelective(caseMainDetailAuxiliaryInfo);
        fastCaseDocumentRecordService.saveFastCaseAutoEndDocument(saveDto);


    }
}
